#ifndef __MAIN_H__
#define __MAIN_H__

#include <stdio.h>

//软件定时器部分的设置gom
#define atAUTO_RELOAD_TIMER_PERIOD (pdMS_TO_TICKS(1000))

typedef struct {
    char wifi_ssid[32];
    char wifi_password[64];
}wifi_param_t;

typedef struct {
    char mqtt_broken_url[60];
    char mqtt_broken_accesskey[60];
    char mqtt_broken_secretkey[60];
    char user_groupid[32];
    uint8_t mqttwork;
    uint8_t decode;
    uint8_t mqttver;
}mqtt_param_t;

typedef struct {
	char software_version[12];
	char hardware_version[12];
	char radar_version[12];
	char device_mac[30];
    char bt_mac[13];
    uint8_t demo_mode;
    uint8_t debug_mode;
    uint8_t silent_ota;
    uint8_t force_upgrade;
    uint8_t initial;
    wifi_param_t wifi_param;
    mqtt_param_t mqtt_param;    
}device_attr_t;
extern device_attr_t device_attr;

typedef enum{
    START = 0,
    IIC_TEST,
    WIFI_TEST,
    RADAR_TEST,
    PWM_TEST,
    REPORT,
    END,
}selftest_state_t;

typedef enum{
    wifi_WAITING = 0,
    wifi_ERROR,
    wifi_FAIL,
    wifi_SUCCESS,
    wifi_TRYING 
}wifi_state_t;

typedef enum{
	BOOTING = 0,
	OTA,
	FAST_SCAN,
	SELF_TEST,
	SMARTCONFIG,
	STATION,
	MQTT_DISCONNECTED,
	NORMAL,
}main_state_t;

typedef struct {
    main_state_t main;
    uint16_t error_ex;
    uint16_t error_now;
	bool time_sync;
    wifi_state_t wifi;
    selftest_state_t selftest;
    bool base_ota;
    bool radar_ota;
}system_state_t;
extern system_state_t system_state;

extern void restart_os(void);
extern void printf_buf(char *tmp_name, uint8_t *tmp_buf, uint8_t tmp_len);
extern void printf_char(char *tmp_name, uint8_t *tmp_buf, uint8_t tmp_len);

#endif